package com.edu.controller.front.food;

import com.edu.service.food.FoodService;
import com.edu.service.food.FoodServiceImpl;
import com.edu.utils.ParamFormat;
import com.edu.utils.ResponseBody;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author ZCN
 * @Date 2021/11/23 21:38
 * @Version 1.0
 **/
// 获取厨师推荐接口
@WebServlet("/front/cookrecommentfoods")
public class CookRecommentServlet extends HttpServlet {
    private FoodService foodService = new FoodServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            ParamFormat.format(req, resp);
            List<Object> cookRecommentFoods = foodService.getCookRecommentFoods();
            List<Object> cookRecomment = cookRecommentFoods.subList(0, 5);
            ResponseBody.success(resp,"success",1L,cookRecomment);
        } catch (Exception e) {
            e.printStackTrace();
            ResponseBody.failure(resp,e.getMessage());
        }
    }
}
